#include "protectedmain.h"
#include <iostream>
#include <sys/mman.h>

constexpr auto PROT_RW = PROT_READ | PROT_WRITE;
constexpr auto MAP_ALLOC = MAP_PRIVATE | MAP_ANONYMOUS;

int protectedMain(int argc, char** argv) noexcept(false)
{
    auto ptr1 = ::mmap(nullptr, 42, PROT_RW, MAP_ALLOC, -1, 0);
    auto ptr2 = ::mmap(nullptr, 42, PROT_RW, MAP_ALLOC, -1, 0);
    std::cout << ptr1 << '\n';
    std::cout << ptr2 << '\n';
    ::munmap(ptr1, 42);
    ::munmap(ptr2, 42);
    return EXIT_SUCCESS;
}